# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=handlr
pkgver=0.6.4
pkgrel=1
pkgdesc="A better xdg-utils - manage mimeapps.list and default applications with ease"
url="https://github.com/chmln/handlr"
arch="aarch64 armhf armv7 ppc64le x86 x86_64"  # limited by rust/cargo
license="MIT"
depends="shared-mime-info"
makedepends="cargo"
subpackages="$pkgname-fish-completion $pkgname-zsh-completion"
source="https://github.com/chmln/handlr/archive/v$pkgver/handlr-$pkgver.tar.gz
	$pkgname-fix-crash-on-readonly-mimeapps-list.patch::https://github.com/chmln/handlr/commit/a782886f05191c1834404d777e74d00f9fa60f7e.patch
	"

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/handlr -t "$pkgdir"/usr/bin/
	install -D -m644 completions/_handlr -t "$pkgdir"/usr/share/zsh/site-functions/
	install -D -m644 completions/handlr.fish -t "$pkgdir"/usr/share/fish/completions/
}

sha512sums="
55779ad0c01e065678e1a57f338272f1d38057658fe6b7c54f7bc35595575aafe13aed6ca3d80cc65b912971aac9a2a6c78ac5512315af9f2d676a92c8c395ec  handlr-0.6.4.tar.gz
2a1a58e000c59f90aa7b3be500d019c135c069d1fba3c8b1f5b7bc8b63b3f9abf02d9268ecc3374b0606d759a4828eda751b1b7ec2e34b86da2412cb04885609  handlr-fix-crash-on-readonly-mimeapps-list.patch
"
